using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Mvc.Ajax;
using Hotnet.Biz.NSBizPicture;
using Hotnet.Entity;
using Hotnet.Biz.NSBizCommon;
using Hotnet.Web.Utility;
using Hotnet.Web.Filters;
using Hotnet.Entity.Enum;
using Hotnet.Entity.Search;

namespace Hotnet.Web.Controllers.Front
{
	[FrontFilter(EnumSystemCategory.图片)]
	public class PictureTagSearchController : FrontBaseController
	{
		private int pageSize = 20;
		private BizPictureGroup bizPictureGroup;
		private BizTag bizTag;
		public PictureTagSearchController(BizPictureGroup bizPictureGroup,BizTag bizTag)
		{
			this.bizPictureGroup=bizPictureGroup;
			this.bizTag = bizTag;
		}
		//
		// GET: /PictureTagSearch/
		public ActionResult Index(int? pageNo,string tagName)
		{
			pageNo=pageNo??0;
			int totalCount=0;
			Tag[] hotTag = bizTag.ListClickHotTag(28, Hotnet.Entity.Enum.EnumTagType.图片);
			IList<string> tagNameList=tagName.Split(new string[]{" "}, StringSplitOptions.RemoveEmptyEntries);
			SearchByTagConditon searchObj = new SearchByTagConditon() { TagName = tagName };
			ViewData["PictureGroups"] =  bizPictureGroup.ListReferenceGroupsByTags(pageSize, pageNo.Value, out totalCount, tagNameList);
			ViewData["PaginateHelper"] = PaginateHelper.ConstructPaginate(totalCount, pageNo ?? 0, PAGE_SIZE, "/PictureTagSearch/Index/", searchObj);
			ViewData["HotPictureTag"] = hotTag;
			ViewData["PictureTagControl"] = new TagControl() { Tags = hotTag.Skip(8).ToArray(), Url = "/PictureTagSearch/Index", IsOpenNewPage = false };
			ViewData["SearchTagName"] = tagName;
			ViewData["HeadControl"] = new HeadControl() { SystemCategory = EnumSystemCategory.图片 };
			return View();
		}
	}
}
